package com.cloudsigns.factorymanager2.project.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.project.adapter.TableContentAdapter;
import com.cloudsigns.factorymanager2.project.adapter.TableLeftAdapter;
import com.cloudsigns.factorymanager2.project.customview.NoscrollListView;
import com.cloudsigns.factorymanager2.project.customview.SyncHorizontalScrollView;

import java.util.ArrayList;
import java.util.List;

/**工程安装进度表
 * Created by tony on 2017/12/20.
 */

public class EngineeringInstallationScheduleTableActivity extends Activity  implements View.OnClickListener {
    private ImageView img_back;
    private TextView tv_title;
    private NoscrollListView mLeft;
    private TableLeftAdapter mLeftAdapter;
    private NoscrollListView mData;
    private TableContentAdapter mDataAdapter;
    private SyncHorizontalScrollView mHeaderHorizontal;
    private SyncHorizontalScrollView mDataHorizontal;
    private List<String> mListData;
    private String TAG = "EngineeringInstallationScheduleTableActivity";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        // 沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    );
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.layout_engineering_installation_schedule_table);

        init();
    }

    private void init() {

        img_back = findViewById(R.id.img_back);
        tv_title = findViewById(R.id.tv_title);


        tv_title.setText(getResources().getText(R.string.engineering_installation_schedule_table));
        img_back.setVisibility(View.VISIBLE);
        img_back.setOnClickListener(this);


        mLeft = (NoscrollListView) findViewById(R.id.lv_left);
        mData = (NoscrollListView) findViewById(R.id.lv_data);
        mDataHorizontal = (SyncHorizontalScrollView) findViewById(R.id.data_horizontal);
        mHeaderHorizontal = (SyncHorizontalScrollView) findViewById(R.id.header_horizontal);

          /*实现两个scrollview联动*/
        mDataHorizontal.setScrollView(mHeaderHorizontal);
        mHeaderHorizontal.setScrollView(mDataHorizontal);

        mListData = new ArrayList<>();
        mListData.add("1");
        mListData.add("1");
        mListData.add("1");
        mListData.add("1");
        mListData.add("1");
        mListData.add("1");


        mLeftAdapter = new TableLeftAdapter(this,TAG, mListData);
        mLeft.setAdapter(mLeftAdapter);

        mDataAdapter = new TableContentAdapter(this, TAG);
        mDataAdapter.setData(mListData);
        mData.setAdapter(mDataAdapter);
    }

    @Override
    public void onClick(View view) {
        Intent mIntent;
        switch (view.getId()) {

            case R.id.img_back:
                finish();
                break;
        }
    }
}
